<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input
        type="text"
        placeholder="enter the name you search"
        v-model="keyword"
        @keyup.enter="getUserList(keyword)"
      />&nbsp;<button @click="getUserList(keyword)">Search</button>
    </div>
  </section>
</template>

<script>
import {mapActions} from 'vuex'
export default {
  name: 'HeaderComponent',
  data(){
    return {
      keyword:undefined
    }
  },
  methods: {
    ...mapActions(['getUserList'])

    // 搜索关键字不能为空
    // handle(keyword){
    //   if(!keyword){
    //     alert('请输入搜索内容后 再试')
    //     return
    //   }else{
    //     this.$store.dispatch('getUserList',keyword)
    //   }
    // }
  },
}
</script>

<style scoped>
</style>
